<template>
	<view class="bannerpage">
		<swiper class="swiper"  circular='false' indicator-dots  
		:current="current"
    @change="onChange"
    @touchstart="onTouchStart"
    @touchend="onTouchEnd">
						<swiper-item>
							<image class="swiper-item" src="https://changban.dianjingkeji.net/img/banner1.jpg" mode=""></image>
						</swiper-item>
						<swiper-item>
							<image class="swiper-item" src="https://changban.dianjingkeji.net/img/banner2.jpg" mode=""></image>
						</swiper-item>
						<swiper-item>
							<image class="swiper-item" src="https://changban.dianjingkeji.net/img/banner3.jpg" mode=""></image>
						</swiper-item>
						<swiper-item>
							<image class="swiper-item" src="https://changban.dianjingkeji.net/img/banner4.jpg" mode=""></image>
						</swiper-item>
						<swiper-item>
							<image class="swiper-item" src="https://changban.dianjingkeji.net/img/banner5.jpg" mode=""></image>
						</swiper-item>
				
					</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				      startX: 0,
				      endX: 0
			}
		},
		methods: {
			
			 onTouchStart(e) {
			      this.startX = e.changedTouches[0].pageX
			    },
			    onTouchEnd(e) {
			      this.endX = e.changedTouches[0].pageX
			      const deltaX = this.startX - this.endX
			
			      // 当前是最后一页，并且左滑距离大于30px
			      if (this.current == 4 && deltaX > 30) {
					  if(uni.getStorageSync('type')==1||uni.getStorageSync('type')==2){
						  uni.redirectTo({
						  	url:'/pages/newxueshu/newxueshu'
						  })
					  }else{
						  uni.redirectTo({
						    url: '/pages/index/index' // ✅ 跳转页面
						  })
					  }
			       
			      }
			    },
			    onChange(e) {
					console.log(e.detail.current)
			      this.current = e.detail.current
			    }
		}
	}
</script>

<style lang="less" scoped>
   .bannerpage{
	   width: 750rpx;
	   height: 100vh;
	   box-sizing: border-box;
	   .swiper{
		   width: 100%;
		   height: 100%;
		   swiper-item{
			   width: 100%;
			   height: 100%;
			   .swiper-item{
			   width: 100%;
			   height: 100%;
			
			   
		   }
		   image{
			   width: 100%;
			   height: 100%;
		   }
			   
		   }
	   }
   }
</style>
